<?php
/**
 * Description of locationclass
 *
 * @author Machiel
 */
class Location {
    private $id;
    private $x;
    private $y;
    
    private $characters;
    private $loadedCharacters = false;
    
    function __construct($id, $x, $y) {
        $this->id = $id;
        $this->x = $x;
        $this->y = $y;
    }

    public function getId() {
        return $this->id;
    }

    /**
     *
     * @global Query $qm
     * @param Character $char
     * @return Character
     */
    function getCharacters($char = '') {
        if(!$this->loadedCharacters) {
            global $qm;
            $this->loadedCharacters = true;
            if($char instanceof Character) {
                $this->characters = $qm->getCharactersFromLocationWithNames($this, $char);
            } else {
                $this->characters = $qm->getCharactersFromLocation($this);
            }
        }

        return $this->characters;
    }

}
?>
